package com.ming.luckyDemo.controller;

import com.ming.luckyDemo.pojo.DO.HistoryLuckyDO;
import com.ming.luckyDemo.pojo.entity.ResultBody;
import com.ming.luckyDemo.service.HistoryLuckyService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;

/**
 * @author Tcm
 */
@RestController
public class HistoryLuckyController {
    @Autowired
    HistoryLuckyService historyLuckyService;

    @PostMapping("/selectHistoryById")
    public ResultBody histroyNumberById(int numbers) {
        List<HistoryLuckyDO> historyLuckyDOS = historyLuckyService.selectLucky(numbers);
        if (historyLuckyDOS.toArray().length<=0){
            return ResultBody.error().message("服务开小差了，请稍后再试！");
        }
        return ResultBody.ok().data("list",historyLuckyDOS);
    }

    @PostMapping("/selectHistory")
    public ResultBody selectHistory() {
        List<HistoryLuckyDO> historyLuckyDOS = historyLuckyService.selectHistory();
        return ResultBody.ok().data("list",historyLuckyDOS);
    }
}
